<template>
	<view>
		<!-- <image class="img" src="" mode=""></image> -->
		<view class="top" :style="'height:'+CustomBar+'px;'">
			<!-- <image :style="'margin-top:'+top+'px; opacity:0'" class="top1img" src="../../static/my/zjt.png" mode=""></image> -->
			<view :style="'margin-top:'+top+'px;'" class="toptext">
				个人中心
			</view>
			<!-- <view class=""></view> -->
		</view>

		<view v-if="istopscroll" class="topyin" :style="'height:'+CustomBar+'px;'">
			<!-- <image :style="'margin-top:'+(top-3)+'px;'" class="top1img" src="/static/sqgl/zjt.png" mode=""></image> -->
			<view :style="'margin-top:'+top+'px;'" class="toptextyin">
				个人中心
			</view>
		</view>

		<view class="top1">
			<view class="">
				<view class="top1text" v-if="token">
					<text style="color: #F8F8F8;">Hi,{{user.nickname}}</text>
				</view>
				<view class="top1text" v-if="!token" @click="$gopage('/pages/login/login')">
					<text style="color: #F8F8F8;">Hi,请登录</text>
				</view>
				<view class="top1-2">
					<image class="top1-2img1" src="https://x.bilinmeiju.com/static/my/anquan.png" mode=""></image>
					<view class="top1-2text">{{user.shenfen}}</view>
				</view>
			</view>
			<view class="top1-3">
				<image class="top1-3img" :src="user.headimgurl" style="border-radius: 50%;" @click="changeheadimgurl"
					mode=""></image>
				<image class="top1-3img1" src="https://x.bilinmeiju.com/static/my/tuoy.png" mode=""></image>
				<image class="top1-3img2" src="https://x.bilinmeiju.com/static/my/pen.png" mode=""></image>
			</view>

		</view>
		<view class="top2">
			<view class="top2-1">
				<text class="top2-1text1">优惠券</text> <text class="top2-1text">{{user.youhuiquan}}</text>
			</view>
			<view class="top2-2">
				<text class="top2-1text1">邻里豆</text> <text class="top2-1text">{{user.linlidou}}</text>
			</view>
			<view class="top2-3">
				<text class="top2-1text1">收藏</text> <text class="top2-1text">{{user.shoucang}}</text>
			</view>
		</view>
		<view class="top3">
			<image class="top3-img" src="http://img.bilinmeiju.com/banner.png" mode=""></image>
		</view>
		<view style="background-color:#F8F8F8;">
			<view class="box">
				<view class="box1" v-if="!vering" @click="$gopage()">
					<view style="height: 37rpx;"></view>
					<view class="box1-1">
						<view class="box1-1-text">
							商城订单
						</view>
						<view class="box1-2">
							<view class="box1-2-text">
								全部订单
							</view>
							<view class="box1-2-2">
								<image class="box1-2-2img" src="https://x.bilinmeiju.com/static/my/yjt.png" mode="">
								</image>
							</view>
						</view>
					</view>
					<view class="box1-3">

						<view class="box1-3-1">
							<view class="box1-3-2">
								<image class="box1-3-2img" src="https://x.bilinmeiju.com/static/my/title1-1.png"
									mode=""></image>
							</view>
							<view class="box1-3-2text">待发货</view>
						</view>
						<view class="box1-3-1">
							<view class="box1-3-2">
								<image class="box1-3-2img2" src="https://x.bilinmeiju.com/static/my/title1-2.png"
									mode=""></image>
							</view>
							<view class="box1-3-2text">待收货</view>
						</view>
						<view class="box1-3-1">
							<view class="box1-3-2">
								<image class="box1-3-2img3" src="https://x.bilinmeiju.com/static/my/title1-3.png"
									mode=""></image>
							</view>
							<view class="box1-3-2text">待评论</view>
						</view>
						<view class="box1-3-1">
							<view class="box1-3-2">
								<image class="box1-3-2img4" src="https://x.bilinmeiju.com/static/my/title1-4.png"
									mode=""></image>
							</view>
							<view class="box1-3-2text">售后/退款</view>
						</view>

					</view>
					<view style="height: 37rpx;"></view>
				</view>
				<view style="height: 20rpx;"></view>
				<view class="box1" v-if="!vering" @click="$gopage()">
					<view style="height: 37rpx;"></view>
					<view class="box1-1">
						<view class="box1-1-text">
							服务订单
						</view>
						<view class="box1-2">
							<view class="box1-2-text">
								全部订单
							</view>
							<view class="box1-2-2">
								<image class="box1-2-2img" src="https://x.bilinmeiju.com/static/my/yjt.png" mode="">
								</image>
							</view>
						</view>
					</view>
					<view class="box1-3">

						<view class="box1-3-1">
							<view class="box1-3-2">
								<image class="box1-3-2img" src="https://x.bilinmeiju.com/static/my/title2-1.png"
									mode=""></image>
							</view>
							<view class="box1-3-2text">待付款</view>
						</view>
						<view class="box1-3-1">
							<view class="box1-3-2">
								<image class="box1-3-2img2" src="https://x.bilinmeiju.com/static/my/title2-2.png"
									mode=""></image>
							</view>
							<view class="box1-3-2text">待核销</view>
						</view>
						<view class="box1-3-1">
							<view class="box1-3-2">
								<image class="box1-3-2img3" src="https://x.bilinmeiju.com/static/my/title2-3.png"
									mode=""></image>
							</view>
							<view class="box1-3-2text">待评论</view>
						</view>
						<view class="box1-3-1">
							<view class="box1-3-2">
								<image class="box1-3-2img4" src="https://x.bilinmeiju.com/static/my/title2-4.png"
									mode=""></image>
							</view>
							<view class="box1-3-2text">售后/退款</view>
						</view>

					</view>
					<view style="height: 37rpx;"></view>
				</view>
				<view style="height: 20rpx;" v-if="!vering" @click="$gopage()"></view>
				<view class="box1">
					<view style="height: 37rpx;"></view>
					<view class="box1-1">
						<view class="box1-1-text">
							常用功能
						</view>
						<view class="box1-2">
							<view class="box1-2-text" @click="quanbu">
								全部
							</view>
							<view class="box1-2-2">
								<image class="box1-2-2img" src="https://x.bilinmeiju.com/static/my/yjt.png" mode="">
								</image>
							</view>
						</view>
					</view>
					<view class="box1-3">

						<view class="box1-3-1" @click="myfangchan">
							<view class="box1-3-2">
								<image class="box1-3-2img" src="https://x.bilinmeiju.com/static/my/title3-1.png"
									mode=""></image>
							</view>
							<view class="box1-3-2text">我的房产</view>
						</view>
						<view class="box1-3-1" @click="mychengyuan">
							<view class="box1-3-2">
								<image class="box1-3-2img2" src="https://x.bilinmeiju.com/static/my/title3-6.png"
									mode=""></image>
							</view>
							<view class="box1-3-2text">我的成员</view>
						</view>
						<view class="box1-3-1" @click="$gopage()">
							<view class="box1-3-2">
								<image class="box1-3-2img2" src="https://x.bilinmeiju.com/static/my/title3-2.png"
									mode=""></image>
							</view>
							<view class="box1-3-2text">我的车辆</view>
						</view>

						<view class="box1-3-1" v-if="!vering" @click="$gopage('/pages/center/openlog/openlog')">
							<view class="box1-3-2">
								<image class="box1-3-2img4" src="https://x.bilinmeiju.com/static/my/title3-4.png"
									mode=""></image>
							</view>
							<view class="box1-3-2text">开门记录</view>
						</view>
					</view>
					<view class="box1-3">
						<view class="box1-3-1" @click="gofangke('/pages/center/fangke/fangkelog')">
							<view class="box1-3-2">
								<image class="box1-3-2img3" src="https://x.bilinmeiju.com/static/my/title3-3.png"
									mode=""></image>
							</view>
							<view class="box1-3-2text">访客通行</view>
						</view>
						<view class="box1-3-1" @click="$gopage('/pages/center/liftpay/zdlist')">
							<view class="box1-3-2">
								<image class="box1-3-2img" src="https://x.bilinmeiju.com/static/my/title3-5.png"
									mode=""></image>
							</view>
							<view class="box1-3-2text">缴费记录</view>
						</view>

						<view class="box1-3-1" v-if="!vering" @click="$gopage()">
							<view class="box1-3-2">
								<image class="box1-3-2img3" src="https://x.bilinmeiju.com/static/my/title3-7.png"
									mode=""></image>
							</view>
							<view class="box1-3-2text">红包卡券</view>
						</view>
						<view class="box1-3-1" v-if="!vering" @click="$gopage()">
							<view class="box1-3-2">
								<image class="box1-3-2img4" src="https://x.bilinmeiju.com/static/my/title3-8.png"
									mode=""></image>
							</view>
							<view class="box1-3-2text">我的发票</view>
						</view>

					</view>
					<view style="height: 37rpx;"></view>
				</view>

				<view style="height: 20rpx;" v-if="!vering" @click="$gopage()"></view>
				<view class="box1" v-if="!vering" @click="$gopage()">
					<view style="height: 37rpx;"></view>
					<view class="box1-1">
						<view class="box1-1-text">
							基本功能
						</view>
						<view class="box1-2">
							<view class="box1-2-text" style="opacity: 0;">
								全部订单
							</view>
							<view class="box1-2-2" style="opacity: 0;">
								<image class="box1-2-2img" src="https://x.bilinmeiju.com/static/my/yjt.png" mode="">
								</image>
							</view>
						</view>
					</view>
					<view class="box1-3">

						<view class="box1-3-1">
							<view class="box1-3-2">
								<image class="box1-3-2img" src="https://x.bilinmeiju.com/static/my/title4-1.png"
									mode=""></image>
							</view>
							<view class="box1-3-2text">地址管理</view>
						</view>
						<view class="box1-3-1">
							<view class="box1-3-2">
								<image class="box1-3-2img2" src="https://x.bilinmeiju.com/static/my/title4-2.png"
									mode=""></image>
							</view>
							<view class="box1-3-2text">客服电话</view>
						</view>
						<view class="box1-3-1">
							<view class="box1-3-2">
								<image class="box1-3-2img3" src="https://x.bilinmeiju.com/static/my/title4-3.png"
									mode=""></image>
							</view>
							<view class="box1-3-2text">分享</view>
						</view>
						<view class="box1-3-1">
							<view class="box1-3-2">
								<image class="box1-3-2img4" style="width: 54rpx;
			height: 54rpx;" src="https://x.bilinmeiju.com/static/my/title4-4.png" mode=""></image>
							</view>
							<view class="box1-3-2text">设置</view>
						</view>

					</view>
					<view style="height: 37rpx;"></view>
				</view>
			</view>
			<view style="height: 200rpx;">

			</view>
		</view>

		<tabbar :selected="3" :vering="vering"></tabbar>
		<box ref="box"></box>
	</view>
</template>

<script>
	var that;
	export default {
		data() {
			return {
				title: 'Hello',
				CustomBar: 0,
				istopscroll: false,
				top: 0,
				user: {
					youhuiquan: 0,
					linlidou: 0.00,
					shoucang: 0
				},
				vering: 1,
				token: '',
				uploadurl: ''
			}
		},

		onPageScroll(e) {

			if (e.scrollTop > 45) {
				this.istopscroll = true
				uni.setNavigationBarColor({
					frontColor: '#000000',
					backgroundColor: '#ffffff',
					animation: {
						duration: 400,
						timingFunc: 'easeIn'
					}
				})
			} else {
				this.istopscroll = false
				uni.setNavigationBarColor({
					frontColor: '#ffffff',
					backgroundColor: '#ffffff',
					animation: {
						duration: 400,
						timingFunc: 'easeIn'
					}
				})
			}
		},
		onShow() {
			uni.hideTabBar({
				animation: false
			})
			this.vering = uni.getStorageSync('vering')
			var token = uni.getStorageSync('token');
			this.token = token;
			if (token) {
				this.$post('center/getuser', {}).then(res => {
					this.user = res.data.user
				})
			} else {
				this.$post('api/getuser', {}).then(res => {
					this.user = res.data.user
				})
			}
			this.$post('api/getuploadurl', {}).then(res => {
				this.uploadurl = res.data.url;
			})
		},
		onLoad() {
			that = this;
			let menuButtonInfo = uni.getMenuButtonBoundingClientRect()
			console.log(menuButtonInfo, 5523);
			this.CustomBar = menuButtonInfo.bottom * 1 + 10
			this.top = menuButtonInfo.top * 1 + (menuButtonInfo.height / 2) - 5


		},
		methods: {
			changeheadimgurl() {
				var that = this;
				if (this.token) {
					var uploadurl = this.uploadurl + '?thumb=400,400'
					uni.chooseImage({
						count: 1, //默认9
						sizeType: ['compressed'], //可以指定是原图还是压缩图，默认二者都有
						sourceType: ['camera', 'album'], //从相册选择
						success: function(res) {
							const imgPath = res.tempFilePaths[0]
							console.log(imgPath);
							uni.uploadFile({
								url: uploadurl,
								filePath: imgPath,
								name: "file",
								success(res) {
									let data = JSON.parse(res.data)
									var imgpath = data.data.url
									that.user.headimgurl = imgpath;
									that.$post('center/upheadimgurl', {
										headimgurl: imgpath
									}).then(res => {
										if (res.code === 0) {
											uni.showToast({
												title: '头像更新成功',
												icon: 'success'
											})
										}
									})
								},
								fail(err) {
									wx.showModal({
										title: '错误提示',
										content: JSON.stringify(err)
									})
								},
								complete(e) {
									// wx.showModal({
									// 	title:'错误提示',
									// 	content:JSON.stringify(e)
									// })
								}
							})
						}

					})
				}
			},
			quanbu() {
				uni.switchTab({
					url: '/pages/index/fuwu'
				})
			},
			showbind() {
				var box = {
					isshow: true,
					title: '请绑定房产',
					content: '请先进行房产绑定',
					content2: '然后进行数据录入',
					btntitle: '去绑定',
					path: '/pages/fangchanbangding/fangchanbangding'
				}
				this.box = box;
				this.$refs.box.open(box)
			},
			gofangke(path) {
				console.log(path)
				//判断我是否有房产
				this.$post('center/getmyroom', {}).then(res => {
					if (res.data.list.length > 0) {
						that.$gopage(path);
					} else {
						that.showbind();
					}
				})
			},
			mychengyuan() {
				uni.navigateTo({
					url: '/pages/mychengyuan/mychengyuan'
				})
			},
			myfangchan() {
				this.$gopage('/pages/myfangchan/myfangchan');
			}
		}
	}
</script>

<style>
	page {
		background: url('https://x.bilinmeiju.com/static/my/biejing.png') no-repeat;
		background-size: 750rpx auto;

	}

	.topyin {
		z-index: 9;
		width: 100%;
		margin: 0 auto;
		display: flex;
		/* justify-content: space-between; */
		background-color: #FFFFFF;
		position: fixed;
		top: 0;
	}

	.toptextyin {
		z-index: 2;
		font-size: 36rpx;
		font-family: Source Han Sans CN;
		font-weight: 500;
		color: #000000;
		line-height: 20rpx;
		text-align: center;
		position: absolute;
		width: 100%;
		text-align: center;
	}

	.img {
		width: 100vw;
		height: 737rpx;
		z-index: 1;
		position: absolute;
		top: 0;
	}

	.top {
		z-index: 2;
		width: 100%;
		margin: 0 auto;
		display: flex;
		/* justify-content: space-between; */
	}


	.toptext {
		z-index: 2;
		font-size: 36rpx;
		font-family: Source Han Sans CN;
		font-weight: 500;
		color: #FFFFFF;
		line-height: 20rpx;
		text-align: center;
		width: 100%;
	}

	.top1img {
		z-index: 2;
		width: 20rpx;
		height: 36rpx;
		margin-left: 20px;
	}

	.top1 {
		width: 700rpx;
		margin: 0 auto;
		margin-top: 30rpx;
		display: flex;
		justify-content: space-between;

	}

	.top1text {
		z-index: 999;
		margin-top: 10rpx;
		font-size: 36rpx;
		font-weight: 400;
		line-height: 36rpx;
		padding-left: 20rpx;
	}

	.top1-2 {
		display: flex;
		margin-top: 18rpx;
		/* flex-direction: column; */

	}

	.top1-2img1 {
		z-index: 2;
		width: 172rpx;
		height: 70rpx;
	}

	.top1-2text {
		z-index: 2;
		margin-left: -100rpx;
		margin-top: 15rpx;
		font-size: 30rpx;
		font-family: PangMenZhengDao;
		font-weight: 400;
		color: #FFFFFF;
		line-height: 30rpx;
	}

	.top1-3 {
		display: flex;
		align-items: flex-end;
	}

	.top1-3img {
		z-index: 2;
		width: 120rpx;
		height: 120rpx;
	}

	.top1-3img1 {
		z-index: 2;
		width: 40rpx;
		height: 40rpx;
		margin-left: -35rpx;
		margin-bottom: 5rpx;
	}

	.top1-3img2 {
		z-index: 2;
		margin-left: -35rpx;
		margin-bottom: 5rpx;
		width: 26rpx;
		height: 30rpx;
	}

	.top2 {
		width: 100vw;
		margin-top: 60rpx;
		display: flex;
		justify-content: space-around;
	}

	.top2-1 {}

	.top2-1text1 {
		font-size: 24rpx;
		font-family: Alibaba PuHuiTi;
		font-weight: 400;
		color: #000000;
		line-height: 40rpx;
	}

	.top2-1text {
		font-size: 40rpx;
		font-family: Alibaba PuHuiTi;
		font-weight: 500;
		color: #000000;
		line-height: 40rpx;
	}

	.top3 {
		margin-top: 44rpx;
		width: 100vw;
	}

	.top3-img {
		width: 745rpx;
		height: 150rpx;
	}

	.box {
		margin-top: 32rpx;
	}

	.box1 {
		background-color: white;
		width: 700rpx;
		margin: 0 auto;
	}

	.box1-1 {

		width: 650rpx;
		margin: 0 auto;

		display: flex;
		justify-content: space-between;
	}

	.box1-2 {
		display: flex;
		align-items: center;
	}

	.box1-2-text {
		font-size: 18rpx;
		font-family: Alibaba PuHuiTi;
		font-weight: 400;
		color: #999999;
		line-height: 36rpx;
	}

	.box1-2-2img {
		margin-left: 10rpx;
		width: 10rpx;
		height: 18rpx;
	}

	.box1-3 {
		/* width: 700rpx; */
		/* margin: 0 auto; */
		margin-top: 35rpx;
		display: flex;
		justify-content: space-around;
	}

	.box1-3-1 {
		display: flex;
		flex-direction: column;
		justify-content: center;
		align-items: center;
	}

	.box1-3-2img {
		width: 65rpx;
		height: 50rpx;
	}

	.box1-3-2text {
		margin-top: 15rpx;
		font-size: 24rpx;
		font-family: Alibaba PuHuiTi;
		font-weight: 400;
		color: #333333;
		line-height: 36rpx;
	}

	.box1-3-2img2 {
		width: 61rpx;
		height: 52rpx;
	}

	.box1-3-2img3 {
		width: 54rpx;
		height: 54rpx;
	}

	.box1-3-2img4 {
		width: 36rpx;
		height: 52rpx;
	}
</style>
